import React, { useEffect, useState } from 'react'
import { useRouteMatch } from 'umi'
import { observer } from 'mobx-react-lite'
import { IRouteComponentProps, useHistory } from 'umi'
// style
// ts
import { IKnowledgeList, IKnowledgeChilrenListChildList } from '@/util/knowledge'
// 时间工具
// context
import useStore from '@/context/useStore'
// view
import KnowledgenotesDetail from '@/components/Knowledgenotes/KnowledgenotesDetail'
const Index: React.FC<IRouteComponentProps> = (props: any) => {
    let history = useHistory()
    // 数据
    let { Knowledge } = useStore()
    let router: any = useRouteMatch()
    let id = props.match.params.id
    let goDetailPage = (item: IKnowledgeList) => {
        history.push(`/knowledgenotes/${item.id}`)
    }
    let goDetailPageID = (ID: string) => {
        // console.log(item);
        history.push(`/knowledgenotes/${id}/${ID}`)
    }
    useEffect(() => {
        let id = props.match.params.id
        id && Knowledge.getKnowledgeID(id)
    }, [props.match.params.id])
    return <KnowledgenotesDetail
        goDetailPage={goDetailPage}
        KnowledgeChilrenList={Knowledge.KnowledgeChilrenList}
        id={id} KnowledgeList={Knowledge.KnowledgeList} goDetailPageID={goDetailPageID}></KnowledgenotesDetail>
}
export default observer(Index)